package com.stray.crawl.exec;

import com.stray.crawl.BeanContext;


public class BeanContainer {

	public static void run(BeanCommand command) {
		BeanContext ctx = null;

		try {
			ctx = BeanContext.getContext();

			command.execute(ctx);
		} catch (Exception ex) {
			ex.printStackTrace();
		} finally {
			if (ctx != null) {
				try {
					ctx.close();
				} catch (Exception e) {
					// ignore
				}
			}
		}

	}

	public interface BeanCommand {

		void execute(BeanContext ctx) throws Exception;

	}

}